package com.maolong.spring.beans;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
public class PropertyValues {
    List<PropertyValue> propertyValueList=new ArrayList<>();

    //解释:指定返回数组类型-->toArray里面的参数
    public PropertyValue[] getPropertyValues(){
        return this.propertyValueList.toArray(new PropertyValue[0]);
    }

    public void addPropertyValue(PropertyValue propertyValue){
        this.propertyValueList.add(propertyValue);
    }

    public PropertyValue getPropertyValue(String name){
        for (PropertyValue propertyValue : propertyValueList) {
            if(propertyValue.getName().equals(name)){
                return propertyValue;
            }
        }
        return null;
    }
}
